home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pas_all.zip
/
TI310.ASC
< prev
next >
Wrap
Text File
|
1992-08-12
|
3KB
|
133 lines
PRODUCT : TURBO PASCAL NUMBER : 310
VERSION : 3.0xx
OS : PC-DOS, MS-DOS
DATE : June 19, 1986 PAGE : 1/2
TITLE : FILE ATTRIBUTES, SETTING & GETTING
Use the following routines to set and get a particular file's
attribute from within a Turbo Pascal program.
type
AnyString = string[80]; { Generic string type }
Registers = record
case Byte of
1 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: integer);
2 : (AL, AH, BL, BH, CL, CH, DL, DH: byte);
end;
function SetFileAttribute(FileName : AnyString;
Attribute : integer) : integer;
{ Sets a particular file's attribute byte - returns error code:
0 - no error
2 - file not found
3 - path not found
5 - access denied
}
var Reg : Registers;
begin
Reg.AH := $43;
Reg.AL := $01;
Reg.CX := Attribute;
FileName := FileName + #0;
{ Make the file name an ASCIIZ string }
Reg.DS := Seg(FileName);
Reg.DX := Succ(Ofs(FileName));
{ The offset of the first char in the name }
MsDos(Reg);
if not (Reg.AX in [2, 3, 5]) then
Reg.AX := 0;
SetFileAttribute := Reg.AX;
end; { SetFileAttribute }
function GetFileAttribute(FileName : AnyString;
var Attribute : integer) : integer;
{ Gets a particular file's attribute byte - returns error code:
0 - no error
2 - file not found
PRODUCT : TURBO PASCAL NUMBER : 310
VERSION : 3.0xx
OS : PC-DOS, MS-DOS
DATE : June 19, 1986 PAGE : 2/2
TITLE : FILE ATTRIBUTES, SETTING & GETTING
3 - path not found
5 - access denied
}
var Reg : Registers;
begin
Reg.AH := $43;
Reg.AL := $00;
FileName := FileName + #0;
{ Make the file name an ASCIIZ string }
Reg.DS := Seg(FileName);
Reg.DX := Succ(Ofs(FileName));
{ The offset of the first char in the name }
MsDos(Reg);
Attribute := Reg.CX;
if not (Reg.AX in [2, 3, 5]) then
Reg.AX := 0;
GetFileAttribute := Reg.AX;
end; { GetFileAttribute }
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.